<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>登录</title>
    <link rel="stylesheet" type="text/css" href="../static/css/reset.css"/>
    <link rel="stylesheet" href="../static/css/style.css">
    <link rel="stylesheet" href="{{ url_for('static',filename='/libs/layui/css/layui.css') }}">
    <script src="{{ url_for('static',filename='/libs/layui/layui.all.js') }}"></script>
    <script src="{{ url_for('static',filename='/libs/jquery-3.5.1.min.js') }}"></script>
</head>
<body>

<div class="outer-container">
    <div class="right">
        <h2 class="title">
            <a href="/towxlogin">微信登录</a>
            <a href="/tologin" class="active">密码登录</a></h2>
        {#        <form class="mt_30" action="/login" method="post">#}
        <form class="mt_30">
            <div class="item_box">
                <div class="input_box">
                    <input type="id_card_phone" id="id_card_phone" name="id_card_phone" placeholder="请输入用户名或手机号码或身份证号"
                           autocomplete="off">
                </div>
            </div>
            <div class="item_box">
                <div class="input_box">
                    <input type="password" id="password" name="password" placeholder="请输入密码" autocomplete="off">
                </div>
            </div>
            <a href="忘记密码.html" class="forget" target="_blank">忘记密码？</a>
            <button class="long mt_28" id="login">登录</button>
        </form>
        <div class="bottom_box mt_60 middle_along">
            <div class="bottom_right">
						<span>
							没有账号？
							<a href="/toregister">立即注册</a>
						</span>
            </div>
        </div>
    </div>
</div>

<script>
    $("#login").click(function (e) {
        e.preventDefault();
        var accout = $("#id_card_phone").val();
        var password = $("#password").val();
        if (accout == "") {
            layer.msg("账号不为空！");
            return false;
        }
        if (password == "") {
            layer.msg("密码不为空！");
            return false;
        }
        $.ajax({
            url: "/login",
            type: "POST",
            data: {
                "id_card_phone": accout,
                "password": password
            },
            success: function (data) {
                if (data.result == 200) {
                    layer.msg('登录中······', {
                        icon: 16
                        , shade: 0.01
                        , time: 1000
                    }, function () {
                        window.location.href="/";
                    });

                } else {
                    layer.msg("账号信息输入有误！")
                }
            },
            error: function (xhr, type, errorThrown) {
                layer.msg("网络有误！")
            }
        })

    })

</script>
</body>
</html>
